package com.hmall.item.web;

import com.hmall.common.dto.ItemDto;
import com.hmall.common.dto.PageResult;
import com.hmall.item.service.IItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("item")
public class ItemController {

    @Autowired
    private IItemService itemService;


    /**
     * 定义分页查询的接口方法
     */
    @GetMapping("/list")
    public PageResult list(@RequestParam("page") Integer page, @RequestParam("size") Integer size){
        return itemService.list(page,size);
    }

    /**
     * 定义新增商品的接口方法
     */
    @PostMapping
    public void saveItem(@RequestBody ItemDto dto){
       itemService.saveItem(dto);
    }
}
